#include <REGX52.H>
#include "delayms.h"
/**
  * @brief 独立按键
  * @param  
  * @param   
  * @retval 按键被按下后的编码（1-4）key1按下返回1
  */
unsigned char GetKeyCode(){
//按下后是低电平
	unsigned char keyCode=0;//赋初值很重要
	if(P3_1==0)//k1
	{
		Delayms(20);
		while(P3_1==0);
		Delayms(20);
		keyCode=1;
	}
	if(P3_0==0)//k2
	{
		Delayms(20);
		while(P3_0==0);
		Delayms(20);
		keyCode=2;
	}
	
	if(P3_0==0)//k2
	{
		Delayms(20);
		while(P3_0==0);
		Delayms(20);
		keyCode=2;
	}
	if(P3_2==0)//k3
	{
		Delayms(20);
		while(P3_2==0);
		Delayms(20);
		keyCode=3;
	}
	
	if(P3_3==0)//k4
	{
		Delayms(20);
		while(P3_3==0);
		Delayms(20);
		keyCode=4;
	}


return keyCode;
}